﻿@model ShippingByWeightModel
@using Grand.Plugin.Shipping.ByWeight.Models;
@using Grand.Framework;
<div asp-validation-summary="All"></div>
<input asp-for="Id" type="hidden" />

@if (ViewBag.RefreshPage == true)
{
    <script type="text/javascript">
        try {window.opener.document.forms['@(Context.Request.Query["formId"])'].@(Context.Request.Query["btnId"]).click();}
        catch (e){}
        window.close();
    </script>
}
<script type="text/javascript">
    $(function () {
        $("#@Html.FieldIdFor(model => model.CountryId)").change(function () {
            var selectedItem = $(this).val();
            var ddlStates = $("#@Html.FieldIdFor(model => model.StateProvinceId)");
            $.ajax({
                cache: false,
                type: "GET",
                url: "@(Url.Action("GetStatesByCountryId", "Home", new RouteValueDictionary { { "area", "Admin" } }))",
                data: { "countryId": selectedItem, "addAsterisk": "true" },
                success: function (data) {
                    ddlStates.html('');
                    $.each(data, function (id, option) {
                        ddlStates.append($('<option></option>').val(option.id).html(option.name));
                    });
                },
                error: function (xhr, ajaxOptions, thrownError) {
                    alert('Failed to retrieve states.');
                }
            });
        });
    });
</script>

<div class="form-horizontal">
    <div class="form-body">
        <div class="form-group">
            <div class="col-md-3 col-sm-3 text-right">
                <admin-label asp-for="StoreId" class="control-label" />
            </div>
            <div class="col-md-9 col-sm-9">
                <admin-select asp-for="StoreId" asp-items="Model.AvailableStores" />
                <span asp-validation-for="StoreId"></span>
            </div>
        </div>
        <div class="form-group">
            <div class="col-md-3 col-sm-3 text-right">
                <admin-label asp-for="WarehouseId" class="control-label" />
            </div>
            <div class="col-md-9 col-sm-9">
                <admin-select asp-for="WarehouseId" asp-items="Model.AvailableWarehouses" />
                <span asp-validation-for="WarehouseId"></span>
            </div>
        </div>
        <div class="form-group">
            <div class="col-md-3 col-sm-3 text-right">
                <admin-label asp-for="CountryId" class="control-label" />
            </div>
            <div class="col-md-9 col-sm-9">
                <admin-select asp-for="CountryId" asp-items="Model.AvailableCountries" />
                <span asp-validation-for="CountryId"></span>
            </div>
        </div>
        <div class="form-group">
            <div class="col-md-3 col-sm-3 text-right">
                <admin-label asp-for="StateProvinceId" class="control-label" />
            </div>
            <div class="col-md-9 col-sm-9">
                <admin-select asp-for="StateProvinceId" asp-items="Model.AvailableStates" />
                <span asp-validation-for="StateProvinceId"></span>
            </div>
        </div>
        <div class="form-group">
            <div class="col-md-3 col-sm-3 text-right">
                <admin-label asp-for="Zip" class="control-label" />
            </div>
            <div class="col-md-9 col-sm-9">
                <admin-input asp-for="Zip" />
                <span asp-validation-for="Zip"></span>
            </div>
        </div>
        <div class="form-group">
            <div class="col-md-3 col-sm-3 text-right">
                <admin-label asp-for="ShippingMethodId" class="control-label" />
            </div>
            <div class="col-md-9 col-sm-9">
                <admin-select asp-for="ShippingMethodId" asp-items="Model.AvailableShippingMethods" />
                <span asp-validation-for="ShippingMethodId"></span>
            </div>
        </div>
        <div class="form-group">
            <div class="col-md-3 col-sm-3 text-right">
                <admin-label asp-for="From" class="control-label" />
            </div>
            <div class="col-md-9 col-sm-9">
                <admin-input asp-for="From" /> [@Model.BaseWeightIn]
                <span asp-validation-for="From"></span>
            </div>
        </div>
        <div class="form-group">
            <div class="col-md-3 col-sm-3 text-right">
                <admin-label asp-for="To" class="control-label" />
            </div>
            <div class="col-md-9 col-sm-9">
                <admin-input asp-for="To" /> [@Model.BaseWeightIn]
                <span asp-validation-for="To"></span>
            </div>
        </div>
        <div class="form-group">
            <div class="col-md-3 col-sm-3 text-right">
                <admin-label asp-for="AdditionalFixedCost" class="control-label" />
            </div>
            <div class="col-md-9 col-sm-9">
                <admin-input asp-for="AdditionalFixedCost" /> [@Model.PrimaryStoreCurrencyCode]
                <span asp-validation-for="AdditionalFixedCost"></span>
            </div>
        </div>
        <div class="form-group">
            <div class="col-md-3 col-sm-3 text-right">
                <admin-label asp-for="LowerWeightLimit" class="control-label" />
            </div>
            <div class="col-md-9 col-sm-9">
                <admin-input asp-for="LowerWeightLimit" />
                <span asp-validation-for="LowerWeightLimit"></span>
            </div>
        </div>
        <div class="form-group">
            <div class="col-md-3 col-sm-3 text-right">
                <admin-label asp-for="RatePerWeightUnit" class="control-label" />
            </div>
            <div class="col-md-9 col-sm-9">
                <admin-input asp-for="RatePerWeightUnit" /> [@Model.PrimaryStoreCurrencyCode]
                <span asp-validation-for="RatePerWeightUnit"></span>
            </div>
        </div>
        <div class="form-group">
            <div class="col-md-3 col-sm-3 text-right">
                <admin-label asp-for="PercentageRateOfSubtotal" class="control-label" />
            </div>
            <div class="col-md-9 col-sm-9">
                <admin-input asp-for="PercentageRateOfSubtotal" />
                <span asp-validation-for="PercentageRateOfSubtotal"></span>
            </div>
        </div>
    </div>
</div>